package com.baizhi.service;

import com.baizhi.dao.ArticleDao;
import com.baizhi.entrty.Article;
import com.baizhi.entrty.ArticleDTO;
import com.baizhi.entrty.Guru;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleDao ad;
    @Override
    public Map fy(int page, int rows) {
        int count = ad.getCount();
        int start = (page-1)*rows;

        Map map = new HashMap();
        List<Article> list = ad.getArticle(start,rows);

        map.put("total",count);
        map.put("rows",list);
        return map;
    }

    @Override
    public void insert(Article ar) {
        ad.insert(ar);
    }

    @Override
    public void delete(int[] id) {

        ad.delete(id);
    }

    @Override
    public List<ArticleDTO> showAll() {
        return ad.showAll();
    }

    @Override
    public List<Article> showArticle() {
        return ad.showArticle();
    }

    @Override
    public List<ArticleDTO> getArticleDto(int userId) {
        return ad.getArticleDto(userId);
    }
}
